import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:http/http.dart';

class NonCacheCircularImage extends StatelessWidget {
  const NonCacheCircularImage(this.imageUrl, this.size, {Key? key})
      : super(key: key);
  final String imageUrl;
  final double size;

  Future<Uint8List> getImageBytes() async {
    Response response = await get(Uri.parse(imageUrl));
    return response.bodyBytes;
  }

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<Uint8List>(
      future: getImageBytes(),
      builder: (context, snapshot) {
        if (snapshot.hasData)
          return Container(
            width: size,
            height: size,
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              image: DecorationImage(
                  image: Image.memory(snapshot.data!).image, fit: BoxFit.cover),
            ),
          );
        return Container();
      },
    );
  }
}
